package artid.com.arttogoa.adapter;

import java.util.List;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;

import artid.com.arttogoa.fragment.ArtImageFragment;
import artid.com.arttogoa.task.CallbackSky;
import artid.com.arttogoa.parser.RecordDetailList;

/**
 * ClassName:MatchFragmentAdapter <br/>
 * Function: 项目页适配器<br/>
 * Reason: 解决项目页标签可以左右滑动的功能 <br/>
 * Date: 2014-2-25 下午4:00:34 <br/>
 * 
 * @author ybq
 * @version
 * @since JDK 1.6
 * @see
 */
public class ArtImageFragmentAdapter extends FragmentStatePagerAdapter {

	private List<RecordDetailList.Pointinformation> mList;
	private CallbackSky call;

	public ArtImageFragmentAdapter(FragmentManager fm, CallbackSky call) {
		super(fm);
		this.call = call;
	}

	public void setData(List<RecordDetailList.Pointinformation> list) {
		mList = list;
		notifyDataSetChanged();
	}

	@Override
	public Fragment getItem(int position) {
		return getFragments(position);
	}

	@Override
	public Object instantiateItem(ViewGroup group, int position) {
		return super.instantiateItem(group, position);
	}

	private Fragment getFragments(int position) {
		ArtImageFragment fragment = new ArtImageFragment(call);

		fragment.setArguments(getBundle(position));
		return fragment;
	}

	private Bundle getBundle(int position) {
		Bundle bundle = new Bundle();
		RecordDetailList.Pointinformation data = mList.get(position);
		bundle.putSerializable("data", data);
		return bundle;
	}

	@Override
	public int getCount() {
		return null == mList ? 0 : mList.size();
	}

	@Override
	public int getItemPosition(Object object) {
		return POSITION_NONE;
	}
}
